#include<bits/stdc++.h>
using namespace std;
template<typename T>inline void read(T &x){
    char ch=getchar();x=0;int f=1;
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    x*=f;
}
const int N=2e5+5;
int k,m,n,l[N],r[N],x[N];
char s[N];
int main(){
	freopen("copy.in","r",stdin);
	freopen("copy.out","w",stdout);
	read(k),read(m);
	scanf("%s",s+1);
	read(n);
	for(int i=1;i<=n;++i) read(l[i]),read(r[i]),read(x[i]);
	for(int i=1;i<=k;++i){
		int v=i;
		for(int j=n;j;--j)
			if(v>x[j]){
				if(v-x[j]<=r[j]-l[j]) v=l[j]+v-x[j];
				else v-=r[j]-l[j];
			}
		putchar(s[v]);
	}
	return 0;
}

